package com.jwell.panprovider.application

import com.facebook.drawee.backends.pipeline.Fresco
import com.jwell.cargoapp.tools.delegates.NotNullSingleValueVar
import com.jwell.panprovider.R
import com.jwell.panprovider.tools.StatuseBarUtils
import com.scwang.smartrefresh.layout.SmartRefreshLayout
import com.scwang.smartrefresh.layout.constant.SpinnerStyle
import com.scwang.smartrefresh.layout.footer.ClassicsFooter
import com.scwang.smartrefresh.layout.header.ClassicsHeader
import com.tencent.tinker.loader.app.TinkerApplication
import com.tencent.tinker.loader.shareutil.ShareConstants

/**
 * Created by老中医 on 2018/3/21.
 * QQ:765773123
 */
class App : TinkerApplication {

    companion object {
        var DEBUG = true
        var instance: App by NotNullSingleValueVar.DelegatesExt.notNullSingleValue()
        var statusHeight: Int = -1

        init {

            //设置全局的Header构建器
            SmartRefreshLayout.setDefaultRefreshHeaderCreater { context, layout ->
                layout.setPrimaryColorsId(R.color.textColor, android.R.color.white)//全局设置主题颜色
                ClassicsHeader(context).setSpinnerStyle(SpinnerStyle.Translate)//指定为经典Header，默认是 贝塞尔雷达Header
            }
            //设置全局的Footer构建器
            SmartRefreshLayout.setDefaultRefreshFooterCreater { context, layout ->
                layout.setPrimaryColorsId(R.color.textColor, android.R.color.white)
                //指定为经典Footer，默认是 BallPulseFooter
                ClassicsFooter(context).setSpinnerStyle(SpinnerStyle.Translate)
            }
        }
    }

    constructor() : super(ShareConstants.TINKER_ENABLE_ALL, "com.jwell.panprovider.application.AppLike", "com.tencent.tinker.loader.TinkerLoader", false)

    override fun onCreate() {
        super.onCreate()
        instance = this
        statusHeight = StatuseBarUtils.getSTATUSTOOLHEIGHT(instance)
        //初始化Fresco
        Fresco.initialize(instance)
        //初始化LeakCanary工具
//        if (!LeakCanary.isInAnalyzerProcess(instance)) LeakCanary.install(this)
    }
}